home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
TECHNICA
/
AUTOCAD
/
H107.ZIP
/
RENUMCNC.ZIP
/
RENUMCNC.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-04-09
|
3KB
|
161 lines
' RENUMCNC - a utility to renumber cnc programs in the emco format
' starting with block '000' to whatever
' assumes file extension of .cnc -- renames old file to .old
' if .old exists it writes over it renumbered file written to .cnc
' -------- start of program -------------
OPTION BASE 1
DEFINT A-Z
CONST true = -1
CONST false = NOT true
DIM isnumber AS INTEGER
CLS
LOCATE 10, 10
PRINT "This program will renumber an existing cnc source file in EMCO format"
LOCATE 12, 10
PRINT "It assumes <infile>.CNC, and will copy the original to <infile>.old"
LOCATE 14, 10
PRINT "and will put the renumbered program in <infile>.CNC"
LOCATE 16, 10
INPUT "input name of file or <CTL>C to abort"; infile$
' ---------------- OPEN FILES --------------------------
infile$ = LTRIM$(RTRIM$(infile$))
temp = INSTR(infile$, ".")
IF (temp = 0) THEN
infile$ = infile$ + ".cnc"
END IF
OPEN infile$ FOR INPUT ACCESS READ AS #1 LEN = 16284
temp = INSTR(infile$, ".")
IF temp = 0 THEN
oldfile$ = infile$ + ".old"
ELSE
oldfile$ = LEFT$(infile$, (temp - 1))
oldfile$ = oldfile$ + ".old"
END IF
OPEN oldfile$ FOR OUTPUT ACCESS WRITE AS #2 LEN = 16284
DO UNTIL EOF(1)
temp$ = ""
LINE INPUT #1, temp$
PRINT #2, temp$
LOOP
CLOSE
OPEN oldfile$ FOR INPUT ACCESS READ AS #1 LEN = 16284
OPEN infile$ FOR OUTPUT ACCESS WRITE AS #2 LEN = 16284
BlockNo = 0
BlockNo$ = ""
DO UNTIL EOF(1)
temp$ = ""
LINE INPUT #1, temp$
isnumber = true
' PRINT "isnumber at #1="; isnumber
IF (MID$(temp$, 4, 3) = "") THEN isnumber = false
' PRINT "is number at #2="; isnumber
IF (isnumber = true) THEN
testval = ASC(MID$(temp$, 4, 1))
' PRINT testval
' SLEEP 1
SELECT CASE testval
CASE IS = 32
' nop
CASE IS < 48
isnumber = false
CASE IS < 59
' nop
CASE IS > 58
isnumber = false
CASE ELSE
isnumber = false
END SELECT
END IF
' PRINT "isnumber at #3="; isnumber
IF (isnumber = true) THEN
testval = ASC(MID$(temp$, 5, 1))
SELECT CASE testval
CASE IS = 32
' nop
CASE IS < 48
isnumber = false
CASE IS < 59
' nop
CASE IS > 58
isnumber = false
CASE ELSE
isnumber = false
END SELECT
END IF
' PRINT "isnumber at #4="; isnumber
IF (isnumber = true) THEN
testval = ASC(MID$(temp$, 6, 1))
SELECT CASE testval
CASE IS = 32
' nop
CASE IS < 48
isnumber = false
CASE IS < 59
' nop
CASE IS > 58
isnumber = false
CASE ELSE
isnumber = false
END SELECT
END IF
' PRINT "isnumber at #5="; isnumber
IF (isnumber = true) THEN
BlockNo$ = STR$(BlockNo)
BlockNo$ = LTRIM$(RTRIM$(BlockNo$))
WHILE LEN(BlockNo$) < 3
BlockNo$ = "0" + BlockNo$
WEND
PRINT BlockNo$
MID$(temp$, 4, 3) = BlockNo$
BlockNo = BlockNo + 1
END IF
PRINT #2, temp$
LOOP
CLOSE
END